//
//  UPResponse.m
//  Uang Pasti
//
//  Created by 李永彬 on 2025/8/16.
//

#import "UPResponse.h"

@implementation UPResponse

+ (UPResponse *) responseWithObject:(id)object
{
    if (!object || ![object isKindOfClass:[NSDictionary class]]) {
        return [self emptyOkResponse];
    }
    
    UPResponse *response = [[UPResponse alloc] init];
    response.lotfication = [[object objectForKey:@"lotfication"] integerValue];
    response.enneasome = [object objectForKey:@"enneasome"];
    response.lapidant = [object objectForKey:@"lapidant"];
    
    return response;
}

+ (UPResponse *) responseWithError:(NSError *)error
{
    UPResponse *response = [[UPResponse alloc] init];
    response.lotfication = error.code;
    response.enneasome = error.description;
    response.lapidant = error.userInfo;
    return response;
}

+ (UPResponse *) emptyOkResponse
{
    UPResponse *response = [[UPResponse alloc] init];
    response.lotfication = 0;
    return response;
}

@end
